package br.com.model.util;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

/**
 *
 * @author Lindoélio Lázaro
 */

public class EntityManagerUtil {

    private static EntityManagerFactory entityManagerLocarWeb;

    private static EntityManagerFactory getEntityManagerFactory() {
        if (entityManagerLocarWeb == null) {
            entityManagerLocarWeb = Persistence.createEntityManagerFactory("LocarWebPU");
        }
        return entityManagerLocarWeb;
    }

    public static EntityManager createEntityManager() {
        return getEntityManagerFactory().createEntityManager();
    }
}
